//
//  BleData.h
//  JC Health
//
//  Created by  on 2020/6/11.
//  Copyright © 2020 杨赛. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "NewBle.h"
#import "bleHeader.h"
NS_ASSUME_NONNULL_BEGIN





typedef void(^ScanDevice) (CBPeripheral* device,NSDictionary<NSString *, id> *advertisementData,NSNumber * RSSI);
typedef void(^ConnectResult) (BOOL success, NSError* _Nullable error);
typedef void(^Disconnect) (NSError* _Nullable error);
typedef void(^Communication) (BOOL canCommunication);
typedef void(^BleResult) (DATATYPE myDataType, NSDictionary* _Nullable dicData,BOOL isEnd);


@interface BleData : NSObject<MyBleDelegate>

+(BleData *)sharedManager;
-(void)setBleDelegate;




-(CBManagerState)getBleStatus;
-(BOOL)isBleConnect;
-(BOOL)isBleConnectOrConnecting;

-(NSArray*)retrieveConnectedPeripherals;

-(void)startScanningWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs deviceBlock:(ScanDevice)scanDevice;
-(void)connectDevice:(CBPeripheral*)device;
-(NSArray*)retrieveConnectedPeripheralsWithStrIdentifier:(NSString*)strIdentifier;
-(void)disConnectDevice;
-(void)StopScan;


#pragma mark 通用
@property (nonatomic,copy)ScanDevice scanDevice;
@property (nonatomic,copy)ConnectResult connectResult;
@property (nonatomic,copy)Disconnect disconnect;
@property (nonatomic,copy)Communication communication;
@property (nonatomic,copy)BleResult bleResult;



#pragma mark 蓝牙方法

-(void)getDeviceVersion;
-(NSString*)getDeviceName;
-(NSString*)getDeviceIdentifier;
-(CBCentralManager*)getCentralManager;
-(void)enterOTAModeWithFileMD5:(NSString*)strFileMD5  signMD5:(NSData*)signMD5;



@end

NS_ASSUME_NONNULL_END
